<template>
	<view class="newsDetail">
		<home :clickColorIndex="3"></home>
		<view class="real-time-info">
			<image class="real-timeImg" src="/static/carousel04.png" mode="aspectFill"></image>
		</view>
		<view class="dynamic-details">
			<view class="newsTitle">{{newsDetail.title}}</view>
			<view class="create_date" v-show="newsDetail.create_date">发布时间：{{formatToDate(newsDetail.create_date)}} <text class="create_text">点击量：{{newsDetail.click}}</text>
			</view>
			<view class="content" v-html="newsDetail.content">
			</view>
		</view>

		<guarantee></guarantee>
		<footing></footing>
		<menu-tool></menu-tool>
	</view>
</template>

<script>
	import {
		getDataList,
		updateNewsClick
	} from '../../utils/http_data.js';
	import {
		formatMillisecondsToDateTime
	} from '../../utils/common.js';
	export default {
		name: "dynamic-details",
		data() {
			return {
				id: '', // 传递过来的数据
				newsDetail: '', // 请求到的新闻数据
			}
		},
		onLoad(option) {
			console.log(option); //打印出上个页面传递的参数。
			this.id = option;
		},
		mounted() {
			this.getDataListDetails()
			updateNewsClick(this.id)
		},
		methods: {
			// 转换年月日时分秒
			formatToDate(val) {
				return formatMillisecondsToDateTime(val)
			},
			// 获取新闻数据
			getDataListDetails() {
				getDataList({
					id: this.id
				}).then((data) => {
					console.log(data.data);
					this.newsDetail = data.data
				})
			},
		}
	}
</script>

<style scoped>
	.newsDetail {
		background-color: #F5F5F5;
	}

	.real-time-info {
		width: 100%;
		height: 500px;
	}

	.real-timeImg {
		width: 100%;
		height: 100%;
	}

	.dynamic-details {
		width: 1200px;
		min-height: 500px;
		background-color: #FFF;
		margin: 30px auto;
		padding: 30px;
		border-radius: 10px;
	}

	.newsTitle {
		font-size: 25px;
		text-align: center;
		margin-bottom: 20px;

	}

	.create_date {
		font-size: 18px;
		text-align: center;
		margin-bottom: 40px;
		color: #A1A1A1;
	}
	
	.create_text {
		font-size: 16px;
		margin-left: 58px;
	}

	.content {
		color: #737373;
		line-height: 30px;
		
	}
</style>